/**
 * @Function: toFixed(n) 保留n位小数
 *   @Author: caigua
 *     @Date: 2016/06/28
 */

define([
    'vue'

], function(Vue) {

    return Vue.filter('toFixed', {
        read: function(num, digit) {
            if (isNaN(num)) {
                num = 0;
            }
            digit = (typeof digit === 'undefined') ? 2 : digit;
            return parseFloat(num).toFixed(digit);
        },
        write: function(num) {
            return parseFloat(num);
        }
    });
});